package models

import (
	"github.com/guregu/null"
	"gorm.io/gorm"
)

type UserRegisterDto struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Email    string `json:"email"`
	Code     string `json:"code"`
}
type UserUpdateDto struct {
	Nickname string `json:"nickname"`
	Gender   int    `json:"gender"`
	Avatar   string `json:"avatar"`
	Intro    string `json:"intro"`
}
type UserLoginDto struct {
	Username string `json:"username"`
	Password string `json:"password"`
}
type UserDetailsVo struct {
	gorm.Model
	Id              int      `gorm:"id" json:"id"`
	Username        string   `gorm:"username" json:"username"`
	Nickname        string   `gorm:"nickname" json:"nickname"`
	Roles           []string `gorm:"-" json:"roles"`
	Gender          int      `gorm:"gender" json:"gender"`
	Avatar          string   `gorm:"avatar" json:"avatar"`
	Intro           string   `gorm:"intro" json:"intro"`
	Email           string   `gorm:"email" json:"email"`
	RegisterType    int      `gorm:"register_type" json:"registerType"`
	RegisterIp      string   `gorm:"register_ip" json:"registerIp"`
	RegisterAddress string   `gorm:"register_address" json:"registerAddress"`
	LoginType       int      `gorm:"login_type" json:"loginType"`
	LoginIp         string   `gorm:"login_ip" json:"loginIp"`
	LoginAddress    string   `gorm:"login_address" json:"loginAddress"`
	IsDisable       int      `gorm:"is_disable;default:0" json:"isDisable"`
	LoginTime       MyTime   `gorm:"login_time" json:"loginTime"`
	CreateTime      MyTime   `gorm:"created_at" json:"createTime"`
	UpdateTime      MyTime   `gorm:"updated_at" json:"updateTime"`
}
type UserAccountVo struct {
	Nickname     string   `json:"nickname"`
	Username     string   `json:"username"`
	RegisterType int      `json:"registerType"`
	Avatar       string   `json:"avatar"`
	Intro        string   `json:"intro"`
	Email        string   `json:"email"`
	Gender       int      `json:"gender"`
	Roles        []string `json:"roles"`
	Permissions  []string `json:"permissions"`
	LoginTime    MyTime   `json:"loginTime"`
	CreateTime   MyTime   `json:"createTime"`
}
type UserSearchDto struct {
	Username        string   `json:"username"`
	Email           string   `json:"email"`
	IsDisable       null.Int `json:"isDisable"`
	CreateTimeStart MyTime   `json:"createTimeStart"`
	CreateTimeEnd   MyTime   `json:"createTimeEnd"`
}
type UserListVo struct {
	gorm.Model
	Id           int    `gorm:"column:id" json:"id"`
	Username     string `gorm:"column:username" json:"username"`
	Nickname 	 string `gorm:"column:nickname" json:"nickname"`
	Avatar       string `gorm:"column:avatar" json:"avatar"`
	Email        string `gorm:"column:email" json:"email"`
	RegisterType int    `gorm:"column:register_type" json:"registerType"`
	LoginAddress string `gorm:"column:login_address" json:"loginAddress"`
	IsDisable    int    `gorm:"column:is_disable;default:0" json:"isDisable"`
	CreateTime   MyTime `gorm:"column:created_at" json:"createTime"`
}
type UpdateUserStatusDto struct {
	Id     int `json:"id"`
	Status int `json:"status"`
}

type User struct {
	gorm.Model
	Id              int    `gorm:"column:id" json:"id"`
	Nickname        string `gorm:"column:nickname" json:"nickname"`
	Email           string `gorm:"column:email" json:"email"`
	Password        string `gorm:"column:password" json:"password"`
	Avatar          string `gorm:"column:avatar" json:"avatar"`
	Gender          int    `gorm:"column:gender;default:0" json:"gender"`
	Intro           string `gorm:"column:intro" json:"intro"`
	Username        string `gorm:"column:username" json:"username"`
	RegisterIp      string `gorm:"column:register_ip" json:"register_ip"`
	RegisterType    int    `gorm:"column:register_type" json:"register_type"`
	RegisterAddress string `gorm:"column:register_address" json:"register_address"`
	LoginIp         string `gorm:"column:login_ip" json:"login_ip"`
	LoginType       int    `gorm:"column:login_type" json:"login_type"`
	LoginAddress    string `gorm:"column:login_address" json:"login_address"`
	IsDisAble       int    `gorm:"column:is_disable;default:0" json:"is_disable"`
	IsDeleted       int    `gorm:"column:is_deleted;default:0" json:"is_deleted"`
	LoginTime       MyTime `gorm:"column:login_time" json:"loginTime"`
}
type UserVo struct {
	gorm.Model
	Id              int    `gorm:"column:id" json:"id"`
	Nickname        string `gorm:"column:nickname" json:"nickname"`
	Email           string `gorm:"column:email" json:"email"`
	Password        string `gorm:"column:password" json:"password"`
	Avatar          string `gorm:"column:avatar" json:"avatar"`
	Gender          int    `gorm:"column:gender;default:0" json:"gender"`
	Intro           string `gorm:"column:intro" json:"intro"`
	Username        string `gorm:"column:username" json:"username"`
	RegisterIp      string `gorm:"column:register_ip" json:"register_ip"`
	RegisterType    int    `gorm:"column:register_type" json:"register_type"`
	RegisterAddress string `gorm:"column:register_address" json:"register_address"`
	LoginIp         string `gorm:"column:login_ip" json:"login_ip"`
	LoginType       int    `gorm:"column:login_type" json:"login_type"`
	LoginAddress    string `gorm:"column:login_address" json:"login_address"`
	IsDisAble       int    `gorm:"column:is_disable;default:0" json:"is_disable"`
	IsDeleted       int    `gorm:"column:is_deleted;default:0" json:"is_deleted"`
	CreateTime      MyTime `gorm:"column:created_at" json:"createTime"`
	UpdateTime      MyTime `gorm:"column:updated_at" json:"updateTime"`
	LoginTime       MyTime `gorm:"column:login_time" json:"loginTime"`
}
type UserDeleteDto struct {
	Ids []int `json:"ids"`
}

func (table *User) TableName() string {
	return "sys_user"
}
func (table *UserVo) TableName() string {
	return "sys_user"
}
func (table *UserListVo) TableName() string {
	return "sys_user"
}
func (table *UserDetailsVo) TableName() string {
	return "sys_user"
}
